package com.ziroom.crm.mq.core.processor.retry

import com.ziroom.crm.mq.core.BaseSpecification
import com.ziroom.crm.mq.core.MqType
import com.ziroom.crm.mq.core.config.MqConfig
import com.ziroom.crm.mq.core.context.InvokeContext
import com.ziroom.crm.mq.core.data.Message
import com.ziroom.crm.mq.core.node.StatisticNode
import com.ziroom.crm.mq.core.processor.QueueWrapper
import com.ziroom.crm.mq.core.retry.RetryConst

import java.time.LocalDateTime
import java.util.function.Consumer

class DefaultReConsumeRetryProcessorTest extends BaseSpecification {
    private InvokeContext invokerContent
    private QueueWrapper queueWrapper


    def setup() {
        def message = new Message(UUID.randomUUID().toString(), "message body")
        def node = new StatisticNode()
        invokerContent = new InvokeContext(message, node)
        def callback = { println(LocalDateTime.now().toString()+":重试方法回调：打印：" + it) } as Consumer
        queueWrapper = new QueueWrapper("my.queue.name", MqType.RABBIT, callback)
    }

    void testPreConsumeWithDefaultConfigSuccess() {
        // 因为spi 也是通过默认构造器加载类的，所以可以通过new 的方式来创建实例
        DefaultReConsumeRetryProcessor consumeRetryProcessor = new DefaultReConsumeRetryProcessor()
        consumeRetryProcessor.preReConsume(invokerContent, queueWrapper)
        expect:
        1==1
    }

    void testPostConsumeWithDefaultConfigSuccess() {
        // 因为spi 也是通过默认构造器加载类的，所以可以通过new 的方式来创建实例
        DefaultReConsumeRetryProcessor consumeRetryProcessor = new DefaultReConsumeRetryProcessor()
        consumeRetryProcessor.postReConsume(invokerContent, queueWrapper)
        expect:
        1==1
    }

}
